package Login_Function;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import JDBC.JDpoor;

public class Login {
	
	Connection con = new JDpoor().CreateCon();
	Statement sql = null;
	PreparedStatement pre = null;
	ResultSet rs = null;
	boolean f = false;
	
	public String login(String phone,String password) {
		String condition = "select name from user_info where phone=? and password=?";
		String name = null;
		
		try {
			pre = con.prepareStatement(condition);
			pre.setString(1, phone);
			pre.setString(2, password);
			rs=pre.executeQuery(); 
			if(rs.next()){
				name = rs.getString("name");
			}
		} catch (Exception e) {
			// TODO: handle exception
			System.out.println(e);
		}
		return name;
	}
}
